-- Starting point is the TidyPlates Knurled theme.
-- <3 data-driven layouts!

local config = {}
local path = "Interface\\Addons\\TidyPlatesLeafed"
local font = path.."\\russellsquarelt.ttf"

function config.SetSpecialText(unit)
	return unit.health.." / "..unit.healthmax
end	

local classByColor =
{
	C285 = "Deathknight",
	C390 = "Druid",
	C498 = "Hunter",
	C549 = "Mage",
	C571 = "Paladin",
	C768 = "Priest",	
	C605 = "Rogue",	
	C335 = "Shaman",	
	C479 = "Warlock",
	C465 = "Warrior",
	--C256 = "Npc",
	-- Tested: Warrior, Rogue, *Priest, *Paladin, Mage, Warlock, Druid, *Shaman, Hunter
	-- Untested: DK
}

-- Goes from class color (set by Blizz) to a class name and thus to an icon.
function config.SetSpecialArt(unit)
	if unit.reaction == "HOSTILE" then
		local r = ceil(unit.red*256)
		local g = ceil(unit.green*256)
		local b = ceil(unit.blue*256)
		local class = nil
		local index = 0
		for index = -2, 3 do
			class = classByColor["C"..(r+g+b+index)]
			--print(r..","..g..","..b)
			--print(r+b+g)
			if class then return path.."\\Class\\ClassIcon_"..class end
		end
	end
	return nil
end				

local artwidth = 256
local artheight = 64

config.healthborder =
{
	texture	= path.."\\NonBorder",
	glowtexture 			= path.."\\Glow",
	elitetexture = path.."\\EliteBorder",
	width = artwidth,
	height = artheight,
	x = 0,
	y = 0,
	anchor = "CENTER",
}

config.threatborder =
{
	texture = path.."\\NonThreat",
	elitetexture = path.."\\EliteThreat",
	width = artwidth,
	height = artheight,
	x = 0,
	y = 0,
	anchor = "CENTER",
}

config.castborder = {
	texture = path.."\\Cast",
	width = artwidth,
	height = artheight,
	x = 0,
	y = 0,
	anchor = "CENTER",
}


config.healthbar = {
	texture 				= path.."\\wglass",
	height = 23,
	width = 110,
	x = 9,
	y = 0,
	anchor = "CENTER",
}

config.castbar = {
	texture 				= path.."\\wglass",
	height = 5,
	width = 107,
	x = 12,
	y = -20,
	anchor = "CENTER",
}

config.spellicon = {
	height = 18,
	width = 18,
	x = 78,
	y = -14,
	anchor = "CENTER",
}

config.name = {
	typeface =					font,
	size = 11,
	width = 108,
	height = 13,
	x = 9,
	y = 7,
	align = "LEFT",
	anchor = "CENTER",
}

config.level = {
	typeface =					font,
	size = 9,
	width = 30,
	height = 13,
	x = -54,
	y = 7,
	align = "CENTER",
	anchor = "CENTER",
}

config.specialText = {
	typeface =					font,
	size = 8,
	width = 108,
	height = 9,
	x = 10,
	y = -6,
	align = "LEFT",
	anchor = "CENTER",
	vertical = "TOP",
}

config.specialArt = {
	width = 22,
	height = 22,
	x = 52,
	y = 0,
	anchor = "CENTER",
}

config.dangerskull =
{
	width = 12,
	height = 12,
	x = -54,
	y = 5,
	anchor = "CENTER",
}

config.raidicon =
{
	width = 18,
	height = 18,
	x = 0,
	y = 9,
	anchor = "TOP",
}

config.frame =
{
	width = 131,
	height = 28,
	x = 0,
	y = 0,
}

config.options =
{
	showEliteColor = false,
	showLevel = true,
	showName = true,
	showSpecialText = true,
	showSpecialArt = true,
	showDangerSkull = true,
	addonVersion = 5,
}

if not TidyPlatesThemeList then TidyPlatesThemeList = {} end
TidyPlatesThemeList["Leafed"] = config

------------------------------------------------------------------
-- Automatically turn on Threat Display
SetCVar("threatWarning", 3)





				
